<%@Page Language="VB"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head>
<title>Simple Repeated-Value Data Binding</title>
<style type="text/css">
body, td {font-family:Tahoma,Arial,sans-serif; font-size:10pt}
input {font-family:Tahoma,Arial,sans-serif; font-size:9pt}
.heading {font-family:Tahoma,Arial,sans-serif; font-size:14pt; font-weight:bold}
.subhead {font-family:Tahoma,Arial,sans-serif; font-size:12pt; font-weight:bold; padding-bottom:5px}
.cite {font-family:Tahoma,Arial,sans-serif; font-size:8pt}
</style></head>
<body bgcolor="#ffffff">
<span class="heading">Simple Repeated-Value Data Binding</span><hr />
<!--------------------------------------------------------------------------->

<table border="0">
<tr><td nowrap="nowrap">


HTML <b>&lt;select&gt;</b> element:<br />
<select id="MySelectList" runat="server" /><p />

<b>&lt;ASP:DropDownList&gt;</b> control:<br />
<ASP:DropDownList id="MyDropDown" runat="server" /><p />

<b>&lt;ASP:ListBox&gt;</b> control:<br />
<ASP:ListBox id="MyASPList" runat="server" /><p />

<b>&lt;ASP:DataGrid&gt;</b> control:<br />
<ASP:DataGrid id="MyDataGrid" runat="server" /><p />

<b>&lt;ASP:Repeater&gt;</b> control:<br />
<ASP:Repeater id="MyRepeater" runat="server">
  <ItemTemplate>
    <%# Container.DataItem %>
  </ItemTemplate>
</ASP:Repeater><p />


</td><td nowrap="nowrap">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</td><td nowrap="nowrap">


<b>&lt;ASP:DataList&gt;</b> control:<br />
<ASP:DataList id="MyDataList" runat="server">
  <ItemTemplate>
    <%# Container.DataItem %>
  </ItemTemplate>
</ASP:DataList><p />

<b>&lt;ASP:CheckBoxList&gt;</b> control:<br />
<ASP:CheckBoxList id="MyCheckList" runat="server" /><p />

<b>&lt;ASP:RadioButtonList&gt;</b> control:<br />
<ASP:RadioButtonList id="MyRadioList" runat="server" /><p />


</td></tr>
</table>

<!--------------------------------------------------------------------------->

<script language="vb" runat="server">

Sub Page_Load()

   'create an ArrayList of values to bind to
   Dim arrValues As New ArrayList(5)
   arrValues.Add("Microsoft")
   arrValues.Add("Sun")
   arrValues.Add("IBM")
   arrValues.Add("Compaq")
   arrValues.Add("Oracle")

   'set the DataSource propert of the controls to the array
   MySelectList.DataSource = arrValues
   MyDropDown.DataSource = arrValues
   MyASPList.DataSource = arrValues
   MyDataGrid.DataSource = arrValues
   MyRepeater.DataSource = arrValues
   MyDataList.DataSource = arrValues
   MyCheckList.DataSource = arrValues
   MyRadioList.DataSource = arrValues

   'bind all the controls on the page
   Page.DataBind()
End Sub

</script>

<!--------------------------------------------------------------------------->
<hr /><span class="cite">[<a href="../global/viewsource.aspx">view source</a>] &nbsp; &nbsp; &nbsp; &nbsp;
&copy;2001 <a class="cite" href="http://www.wrox.com/">Wrox Press</a> -
<a class="cite" href="http://www.wrox.com/Books/Book_Details.asp?isbn=1861004885">Professional ASP.NET</a> (ISBN: 1-861004-88-5)</span>
</body>
</html>
